package com.woniuxy.mapper;

import com.woniuxy.provider.GoodsSqlProvider;
import com.work.framework.pojo.Goods;
import com.work.framework.pojo.GoodsAuctionDTO;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author fengyao
 * @version 1.0
 * @date 2019/9/20 0020 上午 12:30
 */
@Mapper
@Repository
public interface GoodsShowMapper {
    /**
     * 根据商品的状态查询热点商品
     * @param status
     *  0=审核中，默认
     *  1=审核通过，待确定
     *  2=公示期
     *  3=拍卖其
     *  4=流拍
     *  5=已出售
     * @param count 需要取出的数量
     * @param sort 排序
     * @return
     */
    @SelectProvider(type = GoodsSqlProvider.class,method= "hotGoodsByStatus")
    List<GoodsAuctionDTO> selectHotGoodsByStatus(Integer status, Integer count, Boolean sort);

    /**
     * 根据分类查询热点商品
     * @param cid 代表商品类别，商品
     * @param count
     * @param sort
     * @return
     */
    @SelectProvider(type = GoodsSqlProvider.class,method= "hotGoodsByClassify")
    List<GoodsAuctionDTO> selectHotGoodsByClassify(Integer cid, Integer count, Boolean sort);

    /**
     * 获取List列表中集合
     * @param cid 商品类别
     * @param sortType 排序字段
     * @param sort 正序倒叙
     * @param name 商品名称 模糊查询
     * @return 商品集合
     */
    @SelectProvider(type = GoodsSqlProvider.class,method= "showGoodsList")
    List<GoodsAuctionDTO> selectGoodsList(Integer countyid, Integer cid,String sortType, Integer sort,String name);

    /**
     * 返回收藏商品集合
     * @param uid 传入用户id
     * @return 返回商品集合
     */
    @Select("SELECT *  " +
            "FROM goods g INNER JOIN auction a ON g.gid = a.gid AND a.valid = 1 INNER JOIN picture p ON p.gid = g.gid and p.status=0 " +
            "WHERE g.gid in (select e.gid from enshrine e where e.uid=#{uid} and e.flage=1)")
    List<GoodsAuctionDTO> selectEnshrineGoods(Integer uid);


    /**
     * 返回我的拍卖品集合
     * @param uid
     * @return
     */
    @Select("SELECT *  " +
            "FROM goods g INNER JOIN auction a ON g.gid = a.gid AND a.valid = 1 INNER JOIN picture p ON p.gid = g.gid and p.status=0 " +
            "WHERE g.uid=#{uid}")
    List<GoodsAuctionDTO> selectGoodsMyGoods(Integer uid);


    /**
     * 价格区间商品
     * @param min 最小起拍价
     * @param max 最高起拍价
     * @return 返回商品
     */
    @Select("SELECT *  " +
            "FROM goods g INNER JOIN auction a ON g.gid = a.gid AND a.valid = 1 INNER JOIN picture p ON p.gid = g.gid and p.status=0 " +
            "WHERE a.price between #{min} and #{max}")
    List<GoodsAuctionDTO> selectGoodsByMoney(Integer min,Integer max);
}
